package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Commodity;
import cn.wolfcode.trip.base.domain.User;
import cn.wolfcode.trip.base.mapper.CommodityMapper;
import cn.wolfcode.trip.base.mapper.ShopMapper;
import cn.wolfcode.trip.base.query.CommodityQueryObject;
import cn.wolfcode.trip.base.service.ICommodityService;
import cn.wolfcode.trip.base.service.IShopService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class CommodityServiceImpl implements ICommodityService {
    @Autowired
    private CommodityMapper commodityMapper;
    @Autowired
    private ShopMapper shopMapper;

    @Override
    public PageInfo selectCommodity(CommodityQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<Map<String,Object>> list = commodityMapper.selectForList(qo);
        return new PageInfo(list);
    }


    public PageInfo query(CommodityQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<Commodity> list = commodityMapper.selectList(qo);
        return new PageInfo(list);
    }

    @Override
    public Commodity getProduct(Long id) {
        return commodityMapper.selectByPrimaryKey(id);
    }


    @Override
    public Commodity getmoneyByid(Long id) {
        return commodityMapper.selectByPrimaryKey(id);
    }

    @Override
    public void stateByid(Long id) {
        commodityMapper.updatestate(id);

    }

    @Override
    public void nostateByid(Long id) {
        commodityMapper.notstateproduct(id);
    }
}
